define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'taxi/taxidriver/index' + location.search,
                    add_url: 'taxi/taxidriver/add',
                    edit_url: 'taxi/taxidriver/edit',
                    del_url: 'taxi/taxidriver/del',
                    multi_url: 'taxi/taxidriver/multi',
                    import_url: 'taxi/taxidriver/import',
                    table: 'taxidriver',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'usertype', title: __('Usertype')},
                        {field: 'fatherid', title: __('Fatherid')},
                        {field: 'persname', title: __('Persname'), operate: 'LIKE'},
                        {field: 'sex', title: __('Sex'), operate: 'LIKE'},
                        {field: 'age', title: __('Age'), operate: 'LIKE'},
                        {field: 'persid', title: __('Persid'), operate: 'LIKE'},
                        {field: 'address', title: __('Address'), operate: 'LIKE'},
                        {field: 'phone', title: __('Phone'), operate: 'LIKE'},
                        {field: 'city', title: __('City'), operate: 'LIKE'},
                        {field: 'compname', title: __('Compname'), operate: 'LIKE'},
                        {field: 'carnumber', title: __('Carnumber'), operate: 'LIKE'},
                        {field: 'cartype', title: __('Cartype'), operate: 'LIKE'},
                        {field: 'carowner', title: __('Carowner'), operate: 'LIKE'},
                        {field: 'ownertel', title: __('Ownertel'), operate: 'LIKE'},
                        {field: 'nianshendate', title: __('Nianshendate'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'note', title: __('Note')},
                        {field: 'photo', title: __('Photo'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'suoding', title: __('Suoding')},
                        {field: 'admin_id', title: __('Admin_id')},
                        {field: 'user_id', title: __('User_id')},
                        {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
                        {field: 'weixin', title: __('Weixin'), operate: 'LIKE'},
                        {field: 'alipay', title: __('Alipay'), operate: 'LIKE'},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
